package com.old.mapper;

import com.github.pagehelper.Page;
import com.old.annotation.AutoFill;
import com.old.dto.VideoDTO;
import com.old.dto.VideoQueryDTO;
import com.old.entity.Video;
import com.old.enumeration.OperationType;
import com.old.vo.VideoVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VideoMapper {
    //初始化likeman数值为[]
    //插入式时设置为审核态
    @Insert("INSERT INTO video (author_id,video_url,title ,content,create_time,likeMan, isShow) " +
            "VALUES (#{authorId},#{videoUrl},#{title},#{content},#{createTime},'[]',0)")
    @AutoFill(OperationType.INSERT)
    void insertVideo(Video video);

    @Select({"SELECT * FROM video order by create_time DESC"})
    Page<VideoDTO> getVideoList(@Param("searchTerms") String searchTerms);



    // 查询视频详情
    @Select("SELECT * FROM video WHERE id = #{videoId} and isShow = 1")
    Video getVideoDetail(@Param("videoId") Integer videoId);

    //条件查询-获取戏曲列表
    Page<Video> videoListPage(VideoQueryDTO videoQueryDTO);

    @Delete("DELETE FROM video WHERE id = #{videoId}")
    void deleteVideo(Integer videoId);

    List<VideoVO> list(String sort, String searchTerms);

    String getLikeManByVideoId(Integer videoId);

    void updateLikeMan(Integer videoId, String likeMan);

    //审核视频
    @Update("UPDATE video SET isShow = 1 WHERE id = #{videoId}")
    void updateVideoStatus(Integer videoId);

    //检测是否存在该视频
    @Select("select * from video where id = #{videoId}")
    Video checkVideoExist(Integer videoId);

    void batchDeleteByIds(List<Integer> ids);

    VideoVO findOperaDetailById(@Param("id") int id);

    // 返回推荐视频的ID列表
    List<VideoVO> selectVideosWithRecommendFlag(List<Integer> recommendedIds);
}
